<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.util.ArrayList"%>
<%@page import="model.SinhVienModel"%>
<%@page import="model.MonHocModel"%>
<%@page import="model.DangKyModel"%>
<%@page import="common.Constant" %>
<%@page import="dao.MonHocDAO"%>
<%@page import="dao.SinhVienDAO"%>
<%@page import="dao.DangKyDAO"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Đăng Ký Môn Học</title>
<link href="../style/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="JavaScript">
	function themChucNang()
	{
		obj=document.getElementById("cboChuaDangKy");
		str=obj.options[obj.selectedIndex].value;
		if(str!="")
		{
			document.forms['ActionChuaDangKy'].submit();
			
		}
		return ; 
	}

	function huyChucNang()
	{
		obj=document.getElementById("cboDangKy");
		str=obj.options[obj.selectedIndex].value;
		if(str!="")
		{
			document.forms['ActionDangKy'].submit();
			
		}
		return ; 
	}

	function themAllChucNang()
	{
		if(confirm("Bạn có chắc muốn thay đổi")==true)
			document.forms['ActionChuaDangKyAll'].submit();
	}

	function huyAllChucNang()
	{
		if(confirm("Bạn có chắc muốn thay đổi")==true)
			document.forms['ActionDangKyAll'].submit();
		
	}
</script>
</head>
<body onload="pageload();">
	<!-- S HEAD CONTENT -->
	<jsp:include page="../header.jsp" />
	<!-- E HEAD CONTENT -->
	<c:set var="thongke" value='<%=DangKyDAO.ChiTietThongKe(request.getParameter("maSinhVien"))%>' scope="page"></c:set>
	
	<c:set var="tenSinhVien" value = '<%= SinhVienDAO.XemTenSinhVien(request.getParameter("maSinhVien")) %>' scope="session"></c:set>
	<c:set var="listDangKy" value='<%=DangKyDAO.getMonHocDaDangKy(request.getParameter("maSinhVien"))%>'></c:set>
	<c:set var="listChuaDangKy" value='<%=DangKyDAO.getMonHocChuaDangKy(request.getParameter("maSinhVien"))%>'></c:set>
	<c:set var="xemMonHocChuaDangKy" value='<%=DangKyDAO.showAllMonhocChuaDangKyByMaSV(request.getParameter("maSinhVien"))%>'></c:set>
	
	<b>Bạn đang chọn <u>môn học</u> để đăng ký cho sinh viên <u>${tenSinhVien.tenSV}</u></b>	<br></br>
	<form method="post" action="<%=request.getContextPath()%>/thanhVienController?actionType=DangKyMonHoc&actionStatus=huy&maSinhVien=${param.maSinhVien}" name="ActionDangKy" id="ActionDangKy">
		<table align="right">
			<tr>
				<td align="right">Bạn đã đăng ký <b>${thongke.tongChungChi}</b> <u>tín chỉ</u>&nbsp;&nbsp;&nbsp;</td>
			</tr>
			<tr>
				<td align="right">Tổng học phí là <b>${thongke.tongLePhi}</b> <u>VNĐ</u>&nbsp;&nbsp;&nbsp;</td>
			</tr>
			<tr>
				<!-- Thiếu 1 điều kiện -->
				<td align="right"><font color="red"><b>Đăng ký vượt tín chỉ tối đa</b></font>&nbsp;&nbsp;&nbsp;</td>
			</tr>
		</table>	
		<br></br><br></br><br/>
		<table border="1" align="center">					
			<tr>
				<th style='background-color: #186fb2;color:white' width="30px;">STT</th>
				<th style='background-color: #186fb2;color:white' width="45px;">MaMH</th>
				<th style='background-color: #186fb2;color:white' width="100px;">Tên môn học</th>
				<th style='background-color: #186fb2;color:white' width="90px;">TG bắt đầu</th>
				<th style='background-color: #186fb2;color:white' width="90px;">TG kết thúc</th>
				<th style='background-color: #186fb2;color:white' width="50px;">Chứng chỉ</th>
				<th style='background-color: #186fb2;color:white' width="50px;">Lệ phí</th>
			</tr>
				<%int c = 1; %>
					<c:forEach var="obj" items="${xemMonHocChuaDangKy}">
						<tr>
							<td><%=c %></td>
							<td>${obj.maMH }</td>
							<td>${obj.tenMH }</td>
							<td>${obj.thoiGianBatDau }</td>
							<td>${obj.thoiGianKetThuc }</td>
							<td>${obj.chungChi }</td>
							<td>${obj.lePhi }</td>
						</tr>
						<%c++; %>
					</c:forEach>
		</table>	<br></br>
		<table>
			<tr>
				<td><b>DS sinh viên đã đăng ký</b>
					<select multiple="multiple" style="width: 200px; height: 120px;" name="cboDangKy" id="cboDangKy">
						<c:forEach items="${listDangKy}" var="objDangKy">
							<option value="${objDangKy.maMH}">${objDangKy.tenMH}</option>
						</c:forEach>
					</select>
				</td>
				
				<td>
					<!-- <input type='button' onclick="huyChucNang()" value="Xóa một" /> -->
					<img src="<%=request.getContextPath()%>/images/addone.png" height='24' width='65' onclick="huyChucNang()" style="cursor:pointer"/>
	</form>

	<form action="<%=request.getContextPath()%>/thanhVienController?actionType=DangKyMonHoc&actionStatus=huyAll&maSinhVien=${param.maSinhVien}"  method="post" name="ActionDangKyAll" id="ActionDangKyAll">
		 			<!--  <input type="submit" value="Xóa hết"/>--> 
					<img src="<%=request.getContextPath()%>/images/addall.png" height='24' width='65' onclick="huyAllChucNang()" style="cursor:pointer"/>
	</form>	
	
	<form action="<%=request.getContextPath()%>/thanhVienController?actionType=DangKyMonHoc&actionStatus=themAll&maSinhVien=${param.maSinhVien}" name="ActionChuaDangKyAll" id="ActionChuaDangKyAll" method="post" enctype="application/x-www-form-urlencoded">
		 	<!--<input type="submit" value="Thêm hết"/>-->			 	
			<img src="<%=request.getContextPath()%>/images/delall.png" height='24' width='65' onclick="themAllChucNang()" style="cursor:pointer"/>
	</form>		
			
	<form action="<%=request.getContextPath()%>/thanhVienController?actionType=DangKyMonHoc&actionStatus=them&maSinhVien=${param.maSinhVien}" name="ActionChuaDangKy" id="ActionChuaDangKy" method="post">
					<!-- <input type='button' onclick="themChucNang()"  value="Thêm một" />-->
					<img src="<%=request.getContextPath()%>/images/delone.png"  height='24' width='65' onclick="themChucNang()" style="cursor:pointer"/>
				</td>
				
				<td><b>DS sinh viên chưa đăng ký</b>
					<select multiple="multiple" style="width: 200px; height: 120px;" name="cboChuaDangKy" id="cboChuaDangKy">
						<c:forEach items="${listChuaDangKy}" var="objChuaDangKy">
							<option value="${objChuaDangKy.maMH}">${objChuaDangKy.tenMH}</option>
						</c:forEach>
					</select>	
				</td>
			</tr>
	</form>
		</table>


	<div class="div_footer"><br/>
				Copyright©2011. All right reserved.Theme design by HungVuong Group.
	</div></div>	
</body>
</html>